# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         demo003
# Description:
# Author:       $赵怡蕾
# Date:         2019/3/16
#-------------------------------------------------------------------------------

# 父类
class Animal:
    def __init__(self):
        self.name = 'Animal'
        print("Animal 类")

    def eat(self):
        print("它在吃东西")

# 子类
class Dog(Animal):
    def __init__(self):
        super().__init__()
        print(self.name + 'dog')
        print('Dog 类')

    def walk(self):
        print("它会散步")

class Man():
    def helo(self):
        return 'helo helo'

def hello():
    return 'hello'


if __name__ == '__main__':
    animal = Animal()
    animal.eat()
    print('-------------------------')
    dog = Dog()
    dog.walk()
    dog.eat()
    print('-------------------------')
    # 检测子类的方法
    print(issubclass(Dog,Animal))

    m = Man()
    m.name = 'aaa'
    print(hasattr(m,'name'))

    print('-------------------------')
    age = getattr(m,'age',23)
    print(age)

    print('-------------------------')
    # 检测对象是否有helo这个函数，如果没有就返回，hello
    helo1 = getattr(m,'helo',hello)
    print(helo1())